package View;

import Hander.PersonelViewHander;
import util.DimensUtil;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.net.URL;

public class PersonelView extends JFrame {
    //创建视图组件
    JPanel LeftPanel=new JPanel();
    JPanel RightPanel=new JPanel();
    JButton jButton1=new JButton("查询人员信息");
    JButton jButton2=new JButton("查询部门信息");
    JButton jButton3=new JButton("查询项目信息");
    Container contentPane;
    //创建组件监听
    PersonelViewHander personelViewHander;
    // 创建边框
    Border border;
    public PersonelView(){
        super("项目负责人应用界面");
        //初始化边框
        border= BorderFactory.createLineBorder(Color.GRAY, 2);
        contentPane=getContentPane();
        URL imgUrl = PersonelView.class.getResource("/Image/R.png");
        setIconImage(new ImageIcon(imgUrl).getImage());
        Rectangle bounds = DimensUtil.getBounds();
        personelViewHander=new PersonelViewHander(this);

        int width=1495;
        int LeftPanelwidth=120;
        int RightPanelwidth=width-LeftPanelwidth;
        LeftPanel.setPreferredSize(new Dimension(LeftPanelwidth,0 ));
        RightPanel.setPreferredSize(new Dimension(RightPanelwidth, 0));
        RightPanelLayout(contentPane);
        LeftPanelLayout(contentPane);
        contentPane.setLayout(new BorderLayout());
        contentPane.add(LeftPanel,BorderLayout.WEST);
        contentPane.add(RightPanel,BorderLayout.EAST);
        // 根据屏幕大小设计主界面大小
        setBounds(bounds);
        //设置窗体完全充满屏幕大小
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        //设置contentPane窗体信息！
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setResizable(true);
        setVisible(true);
    }

    private void RightPanelLayout(Container contentPane) {
        RightPanel.setBorder(border);
    }
    private void LeftPanelLayout(Container contentPane) {
        SpringLayout springLayout=new SpringLayout();
        LeftPanel.setBorder(border);
        jButton1.addActionListener(personelViewHander);
        jButton2.addActionListener(personelViewHander);
        jButton3.addActionListener(personelViewHander);
        LeftPanel.add(jButton1);
        LeftPanel.add(jButton2);
        LeftPanel.add(jButton3);

    }

    public static void main(String[] args) {
        new PersonelView();
    }
}
